<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="js/jquery-3.1.1.js" type="text/javascript"></script>

<body>
    <h2>新用户注册</h2>
    <form action="AdminRegServlet" method="post">
        注册账号:<input type="text" id="username" name="username"><span id="msg" style="color: darkred"></span><br/>
        注册密码:<input type="password" name="password"><br/>
        <input type="submit" value="注册">
    </form>
    <script>
        $(function () {
            $("#username").blur(function () {
                $.ajax({
                    url:"/CheckNameServlet",
                    type:"POST",
                    data:{
                        "adminName":$("#username").val()
                    },
                    success:function (result) {
                        $("#msg").text(result);
                    }
                })
            })

        })
    </script>
</body>
</html>